<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table">
<div class="content-table-title"><?=$this->title?></div>
<br />
<?php if($this->msg):?>
<div class="replace"><?=$this->msg?></div>
<br />
<?php endif;?>
<form action="/reports/hxb-status" name="form1" method="GET">
查阅日期：<input type="text" name="date_start" id="date_start" style="width: 100px"> ~ <input type="text" name="date_end" id="date_end" style="width: 100px">
&nbsp;&nbsp;&nbsp;&nbsp;
集团：<select name="group_id" id="group_id">
	<option value="">不限</option>
	<?php if(!empty($this->groups)):?>
	<?php foreach($this->groups as $id => $name):?>
	<?php if(!$this->my_group_id_arr[0] || in_array($id, $this->my_group_id_arr)):?>
	<option value="<?=$id?>" <?php if($id == $this->group_id){echo "selected='selected'";}?>><?=$name?></option>
	<?php endif;?>
	<?php endforeach;?>
	<?php endif;?>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;
厂商：<select name="factory_id" id="factory_id">
	<option value="">不限</option>
	<?php if(!empty($this->factories)):?>
	<?php foreach($this->factories as $id => $name):?>
	<?php if(!$this->my_factory_id_arr[0] || in_array($id, $this->my_factory_id_arr)):?>
	<option value="<?=$id?>" <?php if($id == $this->factory_id){echo "selected='selected'";}?>><?=$name?></option>
	<?php endif;?>
	<?php endforeach;?>
	<?php endif;?>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;
省份：<select name="province_id" id="province_id" onchange="GetCities(this.options[this.options.selectedIndex].value);">
					<option value="">不限</option>
					<?php if(!empty($this->provinces)):?>
					<?php foreach($this->provinces as $provinceId => $provinceName):?>
					<option value="<?=$provinceId?>" <?php if($provinceId == $this->province_id){echo "selected='selected'";}?>><?=$provinceName?></option>
					<?php endforeach;?>
					<?php endif;?>
				</select>
&nbsp;&nbsp;
城市：<select name="city_id" id="city_id">
	<option value="">不限</option>
		<?php if(!empty($this->init_cities)):?>
		<?php foreach($this->init_cities as $init_cities):?>
		<option value="<?=$init_cities['cityId']?>" <?php if($init_cities['cityId']==$this->city_id){echo "selected='selected'";}?>><?=$init_cities['cityName']?></option>
		<?php endforeach;?>
		<?php endif;?>
</select>
<br>
排序：<select name="sort_type">
		<option value="1" <?php if(1==$this->sort_type){echo "selected='selected'";}?>>按线索量</option>
		<option value="2" <?php if(2==$this->sort_type){echo "selected='selected'";}?>>按打开次数</option>
	</select>
&nbsp;&nbsp;&nbsp;&nbsp;
关键字：<input type="text" name="keyword" <?php if($this->keyword){echo "value='".$this->keyword."'";}?> />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" class="button" value="搜索" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="button-cancle" value="清空搜索条件" onclick="location.href='?';" />
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?=$this->export_link?>" class="middle blue awesome">导出报表</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<font color="red"><b>当前搜索结果: <?=$this->data['ct']?></b></font>
</form>
<br />

<table style="width: 100%">
  <tr>
    <th>省份</th>
    <th>城市</th>
    <th>厂商</th>
    <th>集团</th>
    <th>经销商ID</th>
    <th>汽车之家ID</th>
    <th>经销商</th>
    <th>销售</th>
    <th>开通日期</th>
    <th>线索量</th>
    <th>打开次数</th>
  </tr>
  <?php $data = $this->data['current_page_info'];?>
  <?php if(2==$this->sort_type){$sort_row = $data["day_active_ct"];}else{$sort_row = $data["day_leads_ct_for_sort"];}?>
  <?php foreach($sort_row as $id => $something):?>
  <tr>
    <td><?=isset($data["provinceName"][$id])?$data["provinceName"][$id]:""?></td>
    <td><?=isset($data["cityName"][$id])?$data["cityName"][$id]:""?></td>
    <td><?=isset($data["factoryName"][$id])?$data["factoryName"][$id]:""?></td>
    <td><?=isset($data["groupName"][$id])?$data["groupName"][$id]:""?></td>
    <td><?=isset($id)?$id:""?></td>
    <td><?=isset($data["_dealerId"][$id])?$data["_dealerId"][$id]:""?></td>
    <td><?=isset($data["companyName"][$id])?$data["companyName"][$id]:""?></td>
    <td><?=isset($data["realName"][$id])?$data["realName"][$id]:""?></td>
    <td><?=isset($data["authTime"][$id])?$data["authTime"][$id]:""?></td>
	<td><?=isset($data["day_leads_ct"][$id])?$data["day_leads_ct"][$id]:0?></td>
    <td><?=isset($data["day_active_ct"][$id])?$data["day_active_ct"][$id]:0?></td>
  </tr>
  <?php endforeach;?>
</table>

<br /><br />
<div align="right"><?=$this->pagination?></div>
<br /><br /><br />

<script>
var date = new Date();//获取当前时间  
date.setDate(date.getDate()-1);
  
$(function() {
	$( "#date_start" ).datepicker({ dateFormat: 'yy-mm-dd', maxDate: date}).datepicker("setDate", "<?=$this->date_start?>");
});

$(function() {
	$( "#date_end" ).datepicker({ dateFormat: 'yy-mm-dd', maxDate: date}).datepicker("setDate", "<?=$this->date_end?>");
});

function GetCities(provinceId)
{
	$.ajax({
			type: "post",
			url : "/ajax/get-cities",
			dataType:'json',
            async:false,
			data: {
					'provinceId':provinceId,
					'type':2
				  },
				success: function(json){
					if(json.result == 1 && typeof(json.data) != "undefined") {
                        var arr = json.data;
						var txt = "<option value=''>不限</option>";
						
                        for(i=0; i < arr.length; i++){
							txt += "<option value='" + arr[i]['cityId'] + "'>" + arr[i]['cityName'] + "</option>";
                        }
						
						document.getElementById("city_id").innerHTML = txt;
                    }
			}
		});
}
</script>
